home *** CD-ROM | disk | FTP | other *** search
/ Young Minds / Young Minds Interactive CD-ROM.ISO / conquest / commands.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-10-26  |  16.0 KB  |  707 lines

  1. /*conquest is copyrighted 1986 by Ed Barlow.
  2.  *  I spent a long time writing this code & I hope that you respect this.  
  3.  *  I give permission to alter the code, but not to copy or redistribute
  4.  *  it without my explicit permission.  If you alter the code, 
  5.  *  please document changes and send me a copy, so all can have it.  
  6.  *  This code, to the best of my knowledge works well,  but it is my first
  7.  *  'C' program and should be treated as such.  I disclaim any
  8.  *  responsibility for the codes actions (use at your own risk).  I guess
  9.  *  I am saying "Happy gaming", and am trying not to get sued in the process.
  10.  *                                                Ed
  11.  */
  12.  
  13. /*    commands.c        */
  14.  
  15. /*include files*/
  16. #include "header.h"
  17. #include <ctype.h>
  18.  
  19. extern short xcurs,ycurs,xoffset,yoffset;
  20. extern FILE *fexe;        /*execute file pointer*/
  21. extern short country;
  22.  
  23. /*change current hex designation*/
  24. redesignate()
  25. {
  26.     char newdes;
  27.     short x,y;
  28.  
  29.     if(country==0){
  30.         mvaddstr(LINES-1,0,"SUPER USER: CHANGE (v)egitation, (e)levation, (d)esig, (o)wner");
  31.         refresh();
  32.         switch(getch()){
  33.         case 'e':
  34.             /*simple contour map definitions*/
  35.             mvprintw(LINES-2,7,"ELEVATIONS: change to %c, %c, %c, %c or %c?",WATER,PEAK,MOUNTAIN,HILL,CLEAR);
  36.             refresh();
  37.             newdes=getch();
  38.             if(newdes!=WATER&&newdes!=PEAK&&newdes!=MOUNTAIN&&newdes!=HILL&&newdes!=CLEAR) return;
  39.             sct[XREAL][YREAL].altitude=newdes;
  40.             /*will fall through as must change vegitation*/
  41.         case 'v':
  42.             /*vegitation types*/
  43.             mvprintw(LINES-2,7,"VEGITATIONS: change to %c, %c, %c, %c, %c, %c, %c, %c, %c, %c, %c or %c?",VOLCANO,DESERT,WASTE,BARREN,LT_VEG,GOOD,WOOD,FORREST,JUNGLE,SWAMP,ICE,NONE);
  44.             refresh();
  45.             newdes=getch();
  46.             if(newdes!=VOLCANO&&newdes!=DESERT&&newdes!=WASTE&&newdes!=BARREN&&newdes!=LT_VEG&&newdes!=NONE&&newdes!=GOOD&&newdes!=WOOD&&newdes!=FORREST&&newdes!=JUNGLE&&newdes!=SWAMP&&newdes!=ICE) return;
  47.             sct[XREAL][YREAL].vegitation=newdes;
  48.             if(isdigit(sct[XREAL][YREAL].vegitation)==0) 
  49.                 sct[XREAL][YREAL].designation=newdes;
  50.             return;
  51.         case 'o':
  52.             mvprintw(LINES-2,7,"what nation owner:");
  53.             refresh();
  54.             scanw("%hd",&x);
  55.             sct[XREAL][YREAL].owner=x;
  56.             return;
  57.         }
  58.     }
  59.     if((country!=0)&&(sct[XREAL][YREAL].owner!=country)) {
  60.         mvprintw(LINES-1,0,"You do not own: hit any key");
  61.         refresh();
  62.         getch();
  63.         return;
  64.     }
  65.     mvprintw(LINES-1,0,"hit space to not redesignate anyting");
  66.     clrtoeol();
  67.     mvprintw(LINES-2,7,"$%d: redesignate to %c, %c, %c, %c or %c?",DESCOST,DMINE,DGOLDMINE,DFARM,DCITY,DCAPITOL);
  68.     clrtoeol();
  69.     refresh();
  70.     /*read answer*/
  71.     newdes=getch();
  72.  
  73.     if(newdes!=DMINE&&newdes!=DGOLDMINE&&newdes!=DFARM&&newdes!=DCITY&&newdes!=DCAPITOL) return;
  74.  
  75.     if((SOWN==country)||(country==0)) {
  76.         if((isdigit(sct[XREAL][YREAL].vegitation)!=0)||(country==0)) {
  77.             if(((newdes!=DCITY)&&(newdes!=DCAPITOL))||(country==0)) {
  78.                 /*decrement treasury*/
  79.                 sct[XREAL][YREAL].designation=newdes;
  80.                 if(country==0) {
  81.                     country=sct[XREAL][YREAL].owner;
  82.                     SADJDES;
  83.                     country=0;
  84.                 }
  85.                 else {
  86.                     SADJDES;
  87.                     ntn[country].tgold-=DESCOST;
  88.                 }
  89.             }
  90.             else if((newdes==DCAPITOL)&&(sct[XREAL][YREAL].designation==DCITY)){
  91.  
  92.                 ntn[country].tgold-=5*DESCOST;
  93.                 ntn[country].tiron-=DESCOST;
  94.                 x=ntn[country].capx;
  95.                 y=ntn[country].capy;
  96.                 sct[x][y].designation=DCITY;
  97.                 if(country==0) {
  98.                     country=sct[x][y].owner;
  99.                     SADJDES2;
  100.                     country=0;
  101.                 }
  102.                 else SADJDES2;
  103.                 sct[XREAL][YREAL].designation=newdes;
  104.                 ntn[country].capx=XREAL;
  105.                 ntn[country].capy=YREAL;
  106.                 if(country==0) {
  107.                     country=sct[XREAL][YREAL].owner;
  108.                     SADJDES;
  109.                     country=0;
  110.                 }
  111.                 else SADJDES;
  112.             }
  113.             else if((newdes==DCAPITOL)&&(sct[XREAL][YREAL].designation!=DCITY)){
  114.                 mvprintw(LINES-1,0,"Sector must be a city: hit any key  ");
  115.             }
  116.             else if((ntn[country].tiron>DESCOST)&&(newdes==DCITY)){
  117.                 if(sct[XREAL][YREAL].people>=500){
  118.                     ntn[country].tgold-=5*DESCOST;
  119.                     ntn[country].tiron-=DESCOST;
  120.                     sct[XREAL][YREAL].designation=newdes;
  121.                     if(country==0) {
  122.                         country=sct[XREAL][YREAL].owner;
  123.                         SADJDES;
  124.                         country=0;
  125.                     }
  126.                     else SADJDES;
  127.                 }
  128.                 else mvprintw(LINES-1,0,"Need 500 people to build to city");
  129.             }
  130.             else mvprintw(LINES-1,0,"Not enough iron: hit any key  ");
  131.         }
  132.         else mvprintw(LINES-1,0,"vegitation unlivable: hit any key  ");
  133.     }
  134.     else mvprintw(LINES-1,0,"Sorry, you don't own sector: hit any key ");
  135.     refresh();
  136. }
  137.  
  138. /*build fort or ship-type */
  139. construct()
  140. {
  141.     int nearsea;
  142.     int cost;
  143.     int x,y;
  144.     short nvynum=0;
  145.     short mnumber,wnumber;
  146.     short isgod=0;
  147.     char type;
  148.  
  149.     if(country==0){
  150.         isgod=1;
  151.         country=sct[XREAL][YREAL].owner;
  152.     }
  153.  
  154.     if(sct[XREAL][YREAL].owner!=country) {
  155.         mvprintw(LINES-1,0,"You do not own: hit any key");
  156.         refresh();
  157.         getch();
  158.         if(isgod==1) country=0;
  159.         return;
  160.     }
  161.  
  162.     if((sct[XREAL][YREAL].designation==DCITY)||(sct[XREAL][YREAL].designation==DCAPITOL)) {
  163.         /*calculate cost for fort*/
  164.         cost=FORTCOST;
  165.         if(isgod==1) cost=0;
  166.         else for(x=1;x<=sct[XREAL][YREAL].fortress;x++) 
  167.             cost*=2;
  168.  
  169.         mvprintw(LINES-2,0,"Do you wish to construct a <f>ort (%d gold) or <s>hips:",cost);
  170.         clrtoeol();
  171.         refresh();
  172.         type=getch();
  173.     }
  174.     else {
  175.         mvprintw(LINES-2,0,"Must construct in city or capitol--hit any key");
  176.         clrtoeol();
  177.         refresh();
  178.         getch();
  179.         return;
  180.     }
  181.  
  182.     /* construct ships*/
  183.     if (type=='s') {
  184.         /*check if next to sea*/
  185.         nearsea=0;
  186.         for(x=XREAL-1;x<=XREAL+1;x++)
  187.             for(y=YREAL-1;y<=YREAL+1;y++)
  188.                 if(sct[x][y].altitude==WATER) nearsea=1;
  189.  
  190.         if (nearsea==0) {
  191.             mvprintw(LINES-2,0,"not in a harbor: hit space");
  192.             clrtoeol();
  193.             refresh();
  194.             getch();
  195.             if(isgod==1) country=0;
  196.             return;
  197.         }
  198.  
  199.         mvprintw(LINES-2,0,"build how many merchant ships:");
  200.         clrtoeol();
  201.         refresh();
  202.         echo();
  203.         scanw("%hd",&mnumber);
  204.         noecho();
  205.         mvprintw(LINES-2,0,"build how many warships:");
  206.         clrtoeol();
  207.         refresh();
  208.         echo();
  209.         scanw("%hd",&wnumber);
  210.         noecho();
  211.         /*sanity checks*/
  212.         if((wnumber>100)||(wnumber<0)) wnumber=0;
  213.         if((mnumber>100)||(mnumber<0)) mnumber=0;
  214.         mvprintw(LINES-2,0,"constructing %hd warships and %hd merchant",wnumber,mnumber);
  215.         clrtoeol();
  216.  
  217.         if((nvynum=getselunit()-MAXARM)>=0){
  218.             if(nvynum>=MAXNAVY){
  219.                 mvaddstr(LINES-1,0,"INVALID NAVY--hit any key");
  220.                 clrtoeol();
  221.                 refresh();
  222.                 getch();
  223.                 if(isgod==1) country=0;
  224.                 return;
  225.             }
  226.             mvaddstr(LINES-1,0,"Do you wish to raise a new fleet (y or n)");
  227.             clrtoeol();
  228.             refresh();
  229.             if(getch()!='y') nvynum=(-1);
  230.         }
  231.  
  232.         if(nvynum<0) {
  233.             mvprintw(LINES-2,0,"raising a new fleet");
  234.             clrtoeol();
  235.             refresh();
  236.  
  237.             nvynum=0;
  238.             x=(-1);
  239.             while((x==(-1))&&(nvynum<MAXNAVY)) {
  240.                 if(NWAR+NMER<=0) {
  241.                     x=nvynum;
  242.                     NWAR=0;
  243.                     NMER=0;
  244.                     NADJSHP;
  245.                 }
  246.                 nvynum++;
  247.             }
  248.             nvynum=x;
  249.         }
  250.  
  251.         if(nvynum==(-1)){
  252.             mvaddstr(LINES-1,0,"NO FREE NAVIES--hit any key");
  253.             clrtoeol();
  254.             refresh();
  255.             getch();
  256.             if(isgod==1) country=0;
  257.             return;
  258.         }
  259.  
  260.         mvprintw(LINES-3,0,"Raising fleet %d",nvynum);
  261.         if((nvynum>=0)&&(nvynum<MAXNAVY)) {
  262.             NXLOC=XREAL;
  263.             NYLOC=YREAL;
  264.             NWAR+=wnumber;
  265.             NMER+=mnumber;
  266.             if(isgod==0) {
  267.             ntn[country].tgold-= (int) wnumber*WARSHPCOST;
  268.             ntn[country].tgold-= (int) mnumber*MERSHPCOST;
  269.             }
  270.             NMOVE=0;
  271.             NADJSHP;
  272.             NADJLOC;
  273.             NADJMOV;
  274.         }
  275.         else mvprintw(LINES-2,0,"ERROR!!!!!!!!!!!!!");
  276.  
  277.         refresh();
  278.         makebottom();
  279.     }
  280.     /* construct fortification points*/
  281.     else if(type=='f'){
  282.         if(sct[XREAL][YREAL].people>=500) {
  283.  
  284.             mvprintw(LINES-1,25,"you build one fort point for %d gold",cost);
  285.             ntn[country].tgold-=cost;
  286.             sct[XREAL][YREAL].fortress++;
  287.             INCFORT;
  288.         }
  289.         else mvprintw(LINES-1,25,"need 500 people");
  290.     }
  291.     else mvprintw(LINES-1,0,"error");
  292.  
  293.     if(isgod==1) country=0;
  294.     refresh();
  295. }
  296.  
  297. /*DRAFT IF IN A CITY*/
  298. draft()
  299. {
  300.     short armynum;
  301.     short men=0;
  302.     short army=(-1);
  303.     short isgod=0;
  304.     if(country==0) {
  305.         isgod=1;
  306.         country=sct[XREAL][YREAL].owner;
  307.     }
  308.     else if(sct[XREAL][YREAL].owner!=country) {
  309.         mvprintw(LINES-1,0,"You do not own: hit any key");
  310.         refresh();
  311.         getch();
  312.         return;
  313.     }
  314.  
  315.     if((sct[XREAL][YREAL].designation!=DCITY)&&(sct[XREAL][YREAL].designation!=DCAPITOL)) {
  316.         mvprintw(LINES-1,0,"must raise in cities: hit any key");
  317.         refresh();
  318.         getch();
  319.         if(isgod==1) country=0;
  320.         return;
  321.     }
  322.  
  323.     if((sct[XREAL][YREAL].designation==DCITY)&&(sct[XREAL][YREAL].people*(2*CITYLIMIT+(ntn[country].tsctrs/2))<ntn[country].tciv)){
  324.         mvprintw(LINES-1,0,"need %d people in city: hit any key",ntn[country].tciv/(2*CITYLIMIT+(ntn[country].tsctrs/2)));
  325.         refresh();
  326.         getch();
  327.         if(isgod==1) country=0;
  328.         return;
  329.     }
  330.  
  331.     if(ntn[country].tgold <= 0){
  332.         mvprintw(LINES-1,0,"you dont have any gold: hit any key");
  333.         refresh();
  334.         getch();
  335.         if(isgod==1) country=0;
  336.         return;
  337.     }
  338.  
  339.     /*raise an untrained army */
  340.     mvprintw(LINES-3,0,"how many men do you wish to raise");
  341.     clrtoeol();
  342.     refresh();
  343.     echo();
  344.     scanw("%hd",&men);
  345.     noecho();
  346.     if(men<=0) return;
  347.     if(men > sct[XREAL][YREAL].people/4) {
  348.         mvprintw(LINES-2,0,"can only raise %d soldiers",sct[XREAL][YREAL].people/4);
  349.         clrtoeol();
  350.         refresh();
  351.         men = sct[XREAL][YREAL].people/4;
  352.     }
  353.     if(men > (short) 10*ntn[country].tiron) {
  354.         mvprintw(LINES-2,0,"aborting--only enough iron for %d troops",ntn[country].tiron/10);
  355.         clrtoeol();
  356.         refresh();
  357.         getch();
  358.         if(isgod==1) country=0;
  359.         return;
  360.     }
  361.     else {
  362.         move(LINES-2,0);
  363.         clrtoeol();
  364.         ntn[country].tiron-= (int) 10*men;
  365.     }
  366.  
  367.     /*count is order of that army in sector*/
  368.     /*armynum is number of that army*/
  369.     if((armynum=getselunit())>=0){
  370.         if(armynum>=MAXARM){
  371.             mvaddstr(LINES-1,0,"INVALID ARMY--hit any key");
  372.             clrtoeol();
  373.             refresh();
  374.             getch();
  375.             if(isgod==1) country=0;
  376.             return;
  377.         }
  378.         mvaddstr(LINES-1,0,"Do you wish to raise a new army");
  379.         clrtoeol();
  380.         refresh();
  381.         if(getch()!='y') army=armynum;
  382.         else army=(-1);
  383.     }
  384.     if(army==(-1)) {
  385.         mvprintw(LINES-2,0,"raising a new army");
  386.         clrtoeol();
  387.         refresh();
  388.         armynum=0;
  389.         while((army==(-1))&&(armynum<MAXARM)) {
  390.             if(ASOLD<=0) {
  391.                 army=armynum;
  392.                 ASOLD=0;
  393.                 AADJMEN;
  394.             }
  395.             armynum++;
  396.         }
  397.         if(army==(-1)){
  398.             mvaddstr(LINES-1,0,"NO FREE ARMIES--hit any key");
  399.             clrtoeol();
  400.             refresh();
  401.             getch();
  402.             if(isgod==1) country=0;
  403.             return;
  404.         }
  405.         armynum=army;
  406.     }
  407.  
  408.     AYLOC=YREAL;
  409.     AXLOC=XREAL;
  410.     AADJLOC;
  411.     AMOVE=0;
  412.     AADJMOV;
  413.     ASTAT=DEFEND;
  414.     AADJSTAT;
  415.     ASOLD+=men;
  416.     AADJMEN;
  417.     sct[XREAL][YREAL].people -= men;
  418.     SADJCIV;
  419.     if(isgod==0)
  420.         /*magiced get 1/2 enlistment costs*/
  421.         if((magic(country,WARRIOR)==1)||(magic(country,WARLORD)==1)||(magic(country,CAPTAIN)==1))
  422.             ntn[country].tgold -= (int) men*ENLISTCOST/2;
  423.         else ntn[country].tgold -= (int) men*ENLISTCOST;
  424.     else country=0;
  425. }
  426.  
  427. /*adjust picked army*/
  428. adjarm()
  429. {
  430.     short status;
  431.     short armynum=0;
  432.     armynum=getselunit();
  433.     if((armynum<0)||(armynum>MAXARM)) {
  434.         beep();
  435.         mvprintw(LINES-1,0,"Sorry you have an Invalid army number (%d)",armynum);
  436.         refresh();
  437.         getch();
  438.         return;
  439.     }
  440.     clear();
  441.     mvprintw(0,10,"ADJUST ARMY %d OF NATION %s",armynum,ntn[country].name);
  442.     mvaddstr(2,10,"1.  March ");
  443.     mvaddstr(3,10,"2.  Scouting--will not engage enemy if possible");
  444.     mvaddstr(4,10,"3.  Attack anybody (Hostile+) within 2 sectors");
  445.     mvaddstr(5,10,"4.  Defend ");
  446.     mvaddstr(6,10,"5.  Garrison--for a city or Capital");
  447.     mvaddstr(12,10,"Enter your choice (return to continue):");
  448.     refresh();
  449.     echo();
  450.     scanw("%hd",&status);
  451.     noecho();
  452.     if((status<1)||(status>5)) return;
  453.     if((status==SCOUT)&&(ASOLD>25)){
  454.         clear();
  455.         mvaddstr(12,(COLS/2)-6,"MUST HAVE < 25 MEN TO SCOUT");
  456.         mvaddstr(13,(COLS/2)-12,"HIT ANY KEY TO CONTINUE");
  457.         refresh();
  458.         getch();
  459.         return;
  460.     }
  461.     ASTAT=status;
  462.     AADJSTAT;
  463. }
  464.  
  465. /*go through MSGFILE not rewriting to temp messages you discard*/
  466. /* then move temp to MSGFILE*/
  467. rmessage()
  468. {
  469.     FILE *mesgfp;
  470.     FILE *fptemp;
  471.     int i;
  472.     int count;
  473.     int contd;
  474.     int done=0;
  475.     char line[80];
  476.     char save[20][80];
  477.  
  478.     clear();
  479.     /*open file*/
  480.     strcpy(line,MSGFILE);
  481.     strcat(line,":temp");
  482.     fptemp=fopen(line,"w");
  483.     if ((mesgfp=fopen(MSGFILE,"r"))==NULL) {
  484.         mvprintw(0,0,"error on read of %s--hit return",MSGFILE);
  485.         refresh();
  486.         getch();
  487.         return;
  488.     }
  489.  
  490.     /*read in file a line at at time*/
  491.     if(fgets(line,80,mesgfp)==NULL) done=1;
  492.     while(done==0) {
  493.         contd=0;
  494.         count=3;
  495.         if(strncmp(line,ntn[country].name,strlen(ntn[country].name))==0) {
  496.             clear();
  497.             standout();
  498.             /*print to end of message*/
  499.             while(contd==0) {
  500.                 if(count<22) strcpy(save[count-3],line);
  501.                 mvprintw(count,0,"%s",line);
  502.                 standend();
  503.                 for(i=0;i<strlen(ntn[country].name);i++) 
  504.                     mvaddch(count,i,' ');
  505.                 count++;
  506.                 if(fgets(line,80,mesgfp)==NULL) contd=1;
  507.                 if(strncmp(line,"END",3)==0) contd=1;
  508.             }
  509.             standout();
  510.             mvaddstr(LINES-3,(COLS/2)-22,"HIT RETURN TO SAVE MESSAGE");
  511.             mvaddstr(LINES-2,(COLS/2)-22,"HIT ANY OTHER KEY TO CONTINUE");
  512.             standend();
  513.             refresh();
  514.             if(getch()=='\n') {
  515.                 for(i=0;i<count-3;i++) fputs(save[i],fptemp);
  516.                 strcpy(line,"END\n");
  517.                 fputs(line,fptemp);
  518.             }
  519.         }
  520.         else fputs(line,fptemp);
  521.         if(fgets(line,80,mesgfp)==NULL) done=1;
  522.     }
  523.     fclose(mesgfp);
  524.     fclose(fptemp);
  525.  
  526.     /*IMPLEMENT A MOVE BETWEEN TMP FILE AND REAL FILE HERE*/
  527.     strcpy(line,"mv ");
  528.     strcat(line,MSGFILE);
  529.     strcat(line,":temp");
  530.     strcat(line," ");
  531.     strcat(line,MSGFILE);
  532.     system(line);
  533. }
  534.  
  535. wmessage()
  536. {
  537.     FILE *fp, *fopen();
  538.     int x,y;
  539.     int done=0;
  540.     char ch;
  541.     char name[12];
  542.     int temp=(-1);
  543.     int linedone;
  544.     char line[100];
  545.     int nationid;
  546.  
  547.     /*what nation to send to*/
  548.     clear();
  549.     mvprintw(0,0,"to send a message to the administrator, send to 'god':");
  550.     mvprintw(2,0,"What country name do you wish to send to:");
  551.     refresh();
  552.     echo();
  553.     getstr(name);
  554.     noecho();
  555.  
  556.     /*is name valid*/
  557.     for(nationid=0;nationid<MAXNTN;nationid++) if(ntn[nationid].active!=0)
  558.         if(strcmp(name,ntn[nationid].name)==0) temp=nationid;
  559.  
  560.     if(strcmp(name,"god")==0) temp=0;
  561.  
  562.     if (temp==(-1)) {
  563.         mvprintw(2,0,"error--invalid name");
  564.         refresh();
  565.         getch();
  566.         return;
  567.     }
  568.  
  569.     if ((fp=fopen(MSGFILE,"a+"))==NULL) {
  570.         mvprintw(4,0,"error opening %s",MSGFILE);
  571.         refresh();
  572.         getch();
  573.         return;
  574.     }
  575.  
  576.     move(0,0);
  577.     clrtoeol();
  578.     move(2,0);
  579.     clrtoeol();
  580.     standout();
  581.     mvprintw(3,(COLS-25)/2,"message to nation %s",name);
  582.     mvprintw(LINES-2,(COLS-25)/2,"end with a return on a new line");
  583.     mvprintw(LINES-1,(COLS-35)/2,"btw... This is my first editor, any comments?");
  584.     standend();
  585.  
  586.     fprintf(fp,"%s Message to %s from %s\n",name,name,ntn[country].name);
  587.     fprintf(fp,"%s \n",name);
  588.     y=6;
  589.     x=0;
  590.     refresh();
  591.     while(done==0) {
  592.         linedone=0;
  593.         ch=' ';
  594.         /*read line*/
  595.         while(linedone==0){
  596.             if(ch=='\b'){
  597.                 if(x>0) x--;
  598.                 mvaddch(y,x,' ');
  599.                 move(y,x);
  600.                 line[x]=' ';
  601.                 refresh();
  602.                 ch=getch();
  603.             }
  604.             else if(ch=='\n') linedone=1;
  605.             else{
  606.                 /*concatonate to end*/
  607.                 line[x]=ch;
  608.                 mvaddch(y,x,ch);
  609.                 if(x<99) x++;
  610.                 else linedone=1;
  611.                 refresh();
  612.                 ch=getch();
  613.             }
  614.         }
  615.         line[x]='\0';
  616.         if(x<=1) done=1;
  617.         /*write to file*/
  618.         fprintf(fp,"%s %s\n",name,line);
  619.         x=0;
  620.         y++;
  621.     }
  622.     fputs("END\n",fp);
  623.     mvprintw(20,0,"Done with messaging");
  624.     fclose(fp);
  625. }
  626.  
  627. /*strategic move of civilians...once only*/
  628. moveciv()
  629. {
  630.     short people;
  631.     short i,j;
  632.  
  633.     mvaddstr(LINES-1,0,"Moving civilians costs 50 per civilian");
  634.     if(sct[XREAL][YREAL].owner!=country){
  635.         mvprintw(LINES-2,0,"you do not own:  hit return");
  636.         clrtoeol();
  637.         refresh();
  638.         getch();
  639.         return;
  640.     }
  641.     else if(sct[XREAL][YREAL].people==0){
  642.         mvaddstr(LINES-2,0,"nobody lives here!!!:  hit return");
  643.         clrtoeol();
  644.         refresh();
  645.         getch();
  646.         makebottom();
  647.         return;
  648.     }
  649.  
  650.     clear();
  651.     mvprintw(0,0,"sector contains %d people",sct[XREAL][YREAL].people);
  652.     mvaddstr(1,0,"how many people to move?");
  653.     clrtoeol();
  654.     refresh();
  655.     echo();
  656.     scanw("%hd",&people);
  657.     noecho();
  658.     if((people<0)||(people>sct[XREAL][YREAL].people)||(people*50>ntn[country].tgold)){
  659.         mvaddstr(4,0,"wrong oh great moosebreath...");
  660.         clrtoeol();
  661.         refresh();
  662.         getch();
  663.         makebottom();
  664.         return;
  665.     }
  666.  
  667.     mvprintw(4,0,"sector location is x=%d, y=%d",XREAL,YREAL);
  668.     mvaddstr(6,0,"what x location to move to?");
  669.     refresh();
  670.     echo();
  671.     scanw("%hd",&i);
  672.     refresh();
  673.     noecho();
  674.  
  675.     if((i-(XREAL))>2||(i-(XREAL))<-2) {
  676.         mvprintw(9,0,"can only move 2 sectors (you tried %hd)...--hit any key",i-(XREAL));
  677.         refresh();
  678.         getch();
  679.         return;
  680.     }
  681.  
  682.     mvaddstr(9,0,"what y location to move to?");
  683.     clrtoeol();
  684.     refresh();
  685.     echo();
  686.     scanw("%hd",&j);
  687.     noecho();
  688.     if((j-(YREAL)>2)||((YREAL)-j>2)) {
  689.         mvprintw(9,0,"can only move 2 sectors (you tried %hd)...--hit any key",j-(XREAL));
  690.         refresh();
  691.         getch();
  692.         return;
  693.     }
  694.     if(sct[XREAL][YREAL].owner!=country){
  695.         mvaddstr(11,0,"you dont own it...");
  696.         clrtoeol();
  697.         refresh();
  698.         getch();
  699.         return;
  700.     }
  701.     ntn[country].tgold-=50*people;
  702.     sct[XREAL][YREAL].people-=people;
  703.     SADJCIV;
  704.     sct[i][j].people+=people;
  705.     SADJCIV2;
  706. }
  707.